import { hasPermission } from '@/directives/permission'

export const STAFF_MANAGE_COLUMNS = [
  {
    name: 'ID',
    key: 'id',
    width: 50,
    fixed: 'left'
  },
  {
    name: '用户名',
    key: 'username',
    width: 120,
    fixed: 'left',
    showOverflowTooltip: true
  },
  {
    name: '昵称',
    key: 'nickname',
    width: 160,
    showOverflowTooltip: true
  },
  {
    name: '邮箱',
    key: 'email',
    width: 200,
    showOverflowTooltip: true
  },
  {
    name: '手机号',
    key: 'tel',
    width: 160
  },
  {
    name: '角色',
    key: 'role',
    width: 160,
    slot: 'role'
  },
  {
    name: '性别',
    key: 'gender',
    width: 80,
    slot: 'gender'
  },
  {
    name: '头像',
    key: 'avatar',
    width: 160,
    slot: 'avatar'
  },
  {
    name: '状态',
    key: 'status',
    slot: 'status'
  },
  {
    name: '年龄',
    key: 'age'
  },
  {
    name: '注册时间',
    key: 'createTime',
    width: 200
  },
  {
    name: '更新时间',
    key: 'updateTime',
    width: 200
  },
  {
    name: '操作',
    key: 'operate',
    fixed: 'right',
    width: 160,
    slot: 'operate',
    hidden: !hasPermission([
      'staff-manage-permission:btn:edit',
      'staff-manage-permission:btn:change-password',
      'staff-manage-permission:btn:delete'
    ])
  }
].filter(o => !o.hidden)

export const RESOURCE_CONFIG_COLUMN = [
  {
    name: '资源名称',
    key: 'name',
    align: 'left'
  },
  {
    name: 'CODE码',
    key: 'code',
    align: 'left'
  },
  {
    name: '资源标识',
    key: 'id',
    width: 100
  },
  {
    name: '类型',
    key: 'type',
    width: 150,
    slot: 'type'
  },
  {
    name: '创建时间',
    key: 'createTime'
  },
  {
    name: '操作',
    key: 'operate',
    fixed: 'right',
    width: 100,
    slot: 'operate',
    hidden: !hasPermission(['resource-config-permission:btn:edit', 'resource-config-permission:btn:edit'])
  }
].filter(o => !o.hidden)

export const ROLE_MANAGE_COLUMN = [
  {
    name: 'ID',
    key: 'id',
    width: 50,
    fixed: 'left'
  },
  {
    name: '角色名称',
    key: 'name',
    align: 'left'
  },
  {
    name: '状态',
    key: 'status',
    slot: 'status',
    width: 150
  },
  {
    name: '类型',
    key: 'type',
    slot: 'type',
    width: 150
  },
  {
    name: '创建时间',
    key: 'createTime'
  },
  {
    name: '更新时间',
    key: 'updateTime'
  },
  {
    name: '操作',
    key: 'operate',
    fixed: 'right',
    width: 180,
    slot: 'operate',
    hidden: !hasPermission([
      'role-manage-permission:btn:edit',
      'role-manage-permission:btn:delete',
      'role-manage-permission:btn:allocate'
    ])
  }
].filter(o => !o.hidden)
